<template>
  <div>
    <van-loading v-if="loading" color="#1989fa" vertical >加载中...</van-loading>
    <van-cell-group inset>
      <van-cell
        v-for="item in list"
        :key="item.id"
        :title="item.bookname"
      />
    </van-cell-group>
  </div>
</template>

<script>
import axios from 'axios';
// 按需加载
import VanCell from 'vant/lib/cell';
import VanCellGroup from 'vant/lib/cell-group';
import VanLoading from 'vant/lib/loading';

// const api = 'http://www.liulongbin.top:3006/api/getbooks';

export default {
  components: {
    VanCell,
    VanCellGroup,
    VanLoading,
  },
  data() {
    return {
      list: [],
      // 初始状态就应该为加载中
      loading: true,
      // finished: false,
    };
  },
  async created () {
    // const res = await axios({
    //   method: 'GET',
    //   url: api,
    // });
    // this.list = res.data.data;
    // // 发完请求置回false
    // this.loading = false;

    // this.finished = true;
    // if (!res.data.hasNext) {
    //   this.finished = true;
    // }

    const res = await axios({
      url: 'http://192.168.12.43:4000/playlist/hot',
      method: 'get',
    });
    console.log(res);
  },
};
</script>

<style scoped>

</style>